function checkData(executeNum, callback, maxNum = 10) {
  if (executeNum >= maxNum) {
    console.log('10秒过去了，但没有检查到内容')
    return
  }
  setTimeout(() => {
    var body = document.body.innerText;
    if (body.substr(0,2)=='[{') {
      callback()
    } else {
        console.log((executeNum + 1)+ '1秒过去了，内容有错误'+document.body.innerText)
        checkData(executeNum + 1, callback)
    }
  }, 1000);
}


function getData() {
  var body = document.body.innerText;

    var t={
       getQueryString:function(name){
          var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
          var r = window.location.search.substr(1).match(reg);
          if(r!=null)
            return  decodeURI(r[2]);
            return null;
       }
   }
    //调用
    var id=t.getQueryString("productTemplateId");//城市名称
    console.log('getData 成功！id:'+id + " body"+body);
    chrome.runtime.sendMessage({ data: { "goat",id,body }, close: true })
}

getData()

chrome.runtime.onMessage.addListener(async (msg, sender) => {
  console.log(msg)
})